package br.com.massai.model.facade;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.Persistence;

public class ProducesEntityManager {
	
	public static final String PERSITENT_UNIT = "massaiPU";

	@Produces @RequestScoped
	public EntityManager createEntityManager(){
		EntityManager em = Persistence.createEntityManagerFactory(PERSITENT_UNIT).createEntityManager();
		em.setFlushMode(FlushModeType.COMMIT);
		return em;
	}
}
